package com.lanchetech.user.controller;

import com.lanchetech.bean.response.HomeInfoResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.entity.Banner;
import com.lanchetech.entity.Navigation;
import com.lanchetech.entity.User;
import com.lanchetech.user.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "首页接口", tags = "首页接口(开放接口)")
@RequestMapping("/api/home")
@RestController
public class HomeController {

    @Autowired
    HomeService homeService;

    @ApiOperation("获取轮播图")
    @GetMapping("/getBanner")
    public ResultData<List<Banner>> getBanner(@RequestParam("scene") Integer scene) {
        return homeService.getBanner(scene);
    }

    @ApiOperation("获取导航菜单")
    @GetMapping("/getNavigation")
    public ResultData<List<Navigation>> getNavigation(@RequestParam("scene") Integer scene) {
        return homeService.getNavigation(scene);
    }

    @ApiOperation("获取首页信息")
    @GetMapping("/getHomeInfo")
    public ResultData<HomeInfoResp> getHomeInfo(@AuthenticationPrincipal User user) {
        return homeService.getHomeInfo(user);
    }

    @ApiOperation("获取自定义首页信息")
    @GetMapping("/getHomeCustom")
    public ResultData<HomeInfoResp> getHomeCustom(@AuthenticationPrincipal User user) {
        return homeService.getHomeCustom(user);
    }


}
